/**
 * create by young (young2f@outlook.com) on 2020/12/3
 */
'use strict';
const model = require('../base/modelBase');
const _ = require('lodash');
module.exports = app => {
    const mongoose = app.mongoose;
    const schema = mongoose.Schema;
    //schema.plugin(require('mongoose-timestamp'));
    // schema.set('timestamps', true);
    const connect = app.mongooseDB.get('aiotBusiness');
    const json = {
        treeId: {type: String, desc: '设备组织'},
        deviceId: {type: String, desc: '设备编码'},
        deviceName: {type: String, desc: '设备名称'},
        recordCode: {type: String, desc: '记录编码'},
        timeStr: {type: String, desc: '时间'},
        time: {type: Number, desc: '时间'},
        value: {type: Number, desc: '电量值'},
        TotalActiveEnergy1: {type: Number, desc: '开始总有功'},
        TotalActiveEnergy2: {type: Number, desc: '结束总有功'},
        startData: {type: Object, desc: '开始数据'},
        endData: {type: Object, desc: '结束数据'}
    };
    const _model = _.cloneDeep(model);
    _.assign(_model, json);
    const _schema = new schema(
        _model
        //{ timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
    );
    return connect.model('PowerMeterDay', _schema);
};
